#ifndef SOCKETSEND_H
#define SOCKETSEND_H
#include <QThread>
#include <QHash>
#include <QDebug>
#include <QtNetwork>

class socketsend : public QThread
{
    Q_OBJECT

public:
    socketsend(QObject *parent = 0);
    ~socketsend();

    void requestData(int ph,const QString &hostName, quint16 port,int type,QByteArray data);
    void exit();
    void run() override;
    int getId(){return pthread;}

public slots:
    //void get();

signals:
    void getData(int hd,int code,QString answer);
    void error(int hd,int socketError, const QString &message);
    void threadexit(int hd);

private:
    void startTimer(int ntime);
    void killTimer();
    void overtime();
    QMutex mutex;
    QWaitCondition condition;
    bool abort;

    int pthread;
    QString hostName;
    quint16 port;
    QByteArray data;
    int m_type;

    QByteArray by;

    QTimer *pTimer;
};

#endif // SOCKETSEND_H
